package com.sinosoft.ebusiness.domain.elementManage;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sinosoft.ebusiness.domain.elementManage.GeProduct;
import com.sinosoft.ebusiness.domain.elementManage.GeProductKindCalcuteId;
import com.sinosoft.ebusiness.domain.elementManage.GeProductPremiumCalcuteFormula;


@Entity
@Table(name = "GE_PRODUCT_KIND_CALCUTE")
public class GeProductKindCalcute implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8348240345824823788L;

	/**
	 * 
	 */

	private GeProductKindCalcuteId id;
	
	private String remark;
	
	private GeProduct geProduct;
	
	private List<GeProductPremiumCalcuteFormula> geProductPremiumCalcuteFormulas = new ArrayList<GeProductPremiumCalcuteFormula>(0);

	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "PRODUCTCODE", column = @Column(name = "PRODUCTCODE")),
			@AttributeOverride(name = "VERSION", column = @Column(name = "VERSION")),
			@AttributeOverride(name = "KINDCODE", column = @Column(name = "KINDCODE"))})
	public GeProductKindCalcuteId getId() {
		return id;
	}
	public void setId(GeProductKindCalcuteId id) {
		this.id = id;
	}

	@Column(name = "REMARK")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	@JsonBackReference
	@JsonIgnore
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumns({
			@JoinColumn(name = "PRODUCTCODE", referencedColumnName = "PRODUCTCODE", nullable = false, insertable = false, updatable = false),
			@JoinColumn(name = "VERSION", referencedColumnName = "VERSION", nullable = false, insertable = false, updatable = false) })
	public GeProduct getGeProduct() {
		return geProduct;
	}

	public void setGeProduct(GeProduct geProduct) {
		this.geProduct = geProduct;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "geProductKindCalcute")
	public List<GeProductPremiumCalcuteFormula> getGeProductPremiumCalcuteFormulas() {
		return geProductPremiumCalcuteFormulas;
	}
	public void setGeProductPremiumCalcuteFormulas(
			List<GeProductPremiumCalcuteFormula> geProductPremiumCalcuteFormulas) {
		this.geProductPremiumCalcuteFormulas = geProductPremiumCalcuteFormulas;
	}

	
	
	
}
